class Solution {
    public String minWindow(String s, String t) {
        char[] ss = s.toCharArray();
        char[] tt = t.toCharArray();
        int[] hash1 = new int[128];
        int[] hash2 = new int[128];
        int count = 0;
        int start = -1;
        int kinds=0;
        int len = Integer.MAX_VALUE;
        for (int i = 0; i < tt.length; i++) {
            char in = tt[i];
            if(hash1[in]==0){
                kinds++;
            }
            hash1[in]++;
        }
        for (int right = 0, left = 0; right < ss.length; right++) {
            char in = ss[right];
            hash2[in]++;
            if (hash2[in] <= hash1[in]) {
                count++;
            }
            while (count ==t.length()) {
                if(right-left+1<len){
                    start = left;
                    len = Math.min(len, right - left + 1);
                }

                char out = ss[left];
                if (hash2[out] <=hash1[out]) {
                    count--;
                }
                hash2[out]--;
                left++;


            }
        }
        if(start==-1){
            return "";
        }
        String str = s.substring(start,start+len);
        return str;


    }
}